<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/PartProgress/partProgress" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="partProgress" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >订单号：</label>
            <input type="text" name="docId"  value="${docId}" size="16" placeholder="订单号"/>&nbsp;
            <label >产品编码：</label>
            <input type="text" name="partName"  value="${partName}" size="16" placeholder="产品编码"/>&nbsp;
            <label >产品名称：</label>
            <input type="text" name="partDesc" value="${partDesc}" size="16" placeholder="产品名称"/>&nbsp;
            <label >内部图号：</label>
            <input type="text" name="group3" value="${group3}" size="16" placeholder="内部图号"/>&nbsp;
            <label >工序：</label>
            <g:select name="step" from="${partProgressStepList}" data-toggle="selectpicker" data-live-search="true"
                      optionKey="step" optionValue="step" value="${step}" data-width="130" noSelection="['':'-- All --']" />&nbsp;
            <br /><br />
            <label >时间段：</label>
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy/MM/dd" size="12" data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy/MM/dd" size="12" data-toggle="datepicker" placeholder="TO">&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/OncePassYieldByMonth/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${partProgress.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th width="150"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${partProgress.size()>0}">
                <g:each in="${partProgress}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance!='RN'&&headInstance!='WAIT'&&headInstance!='RUN'&&headInstance!='HOLD'&&headInstance!='REPAIR'&&headInstance!='OUTSRC'&&headInstance!='SCRAP'&&headInstance!='STEP_QTY_SUM'}">
                                <td >${dataInstance["${headInstance}"]}</td>
                            </g:if>
                            <g:elseif test="${headInstance=='STEP_QTY_SUM'&&headInstance!='RN'}">
                                <td name="PROGRESSSTEPSUM${i}">${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='WAIT'||headInstance=='RUN'||headInstance=='HOLD'||headInstance=='REPAIR'||headInstance=='OUTSRC'||headInstance=='SCRAP'}">
                                <td name="PROGRESS${headInstance+i}"><a href="${request.getContextPath()}/PartProgress/partProgressStep?state1=<%=headInstance%>&partName1=<%=dataInstance.PART_NAME%>&stepName1=<%=dataInstance.STEP_NAME%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'partProgressStep', title:'产品进度跟踪二阶'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>

                        </g:each>
                    </tr>
                </g:each>
                <tr>
                    <td colspan="10">小计</td>
                    <td name="progressWaitShow"></td>
                    <td name="progressRunShow"></td>
                    <td name="progressHoldShow"></td>
                    <td name="progressRepairShow"></td>
                    <td name="progressOutsrcShow"></td>
                    <td name="progressScrapShow"></td>
                    <td name="progressStepSum"></td>
                </tr>
                <tr>
                    <td colspan="10">合计</td>
                    <td>${partProgressSumQty.SUM_WAIT[0]}</td>
                    <td>${partProgressSumQty.SUM_RUN[0]}</td>
                    <td>${partProgressSumQty.SUM_HOLD[0]}</td>
                    <td>${partProgressSumQty.SUM_REPAIR[0]}</td>
                    <td>${partProgressSumQty.SUM_OUTSRC[0]}</td>
                    <td>${partProgressSumQty.SUM_SCRAP[0]}</td>
                    <td>${partProgressSumQty.STEP_QTY_SUM[0]}</td>
                </tr>

            </g:if>
            </tbody>
        </table>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel" />
    </g:else>
</div>
<g:render template="../template/pagination" />
<script>
    $(function(){


        var progressWait=0;
        var progressRun=0;
        var progressHold=0;
        var progressRepair=0;
        var progressOutsrc=0;
        var progressScrap=0;
        var progressStepSum=0;
        for(var i=0;i<${partProgress.size()};i++){

            var progresswait='PROGRESSWAIT'+i
            var progressWaitAdd=$("td[name='"+progresswait+"']").text()==''?0:parseInt($("td[name='"+progresswait+"']").text());
            progressWait+=progressWaitAdd;

            var progressrun='PROGRESSRUN'+i
            var progressRunAdd=$("td[name='"+progressrun+"']").text()==''?0:parseInt($("td[name='"+progressrun+"']").text());
            progressRun+=progressRunAdd;

            var progresshold='PROGRESSHOLD'+i
            var progressHoldAdd=$("td[name='"+progresshold+"']").text()==''?0:parseInt($("td[name='"+progresshold+"']").text());
            progressHold+=progressHoldAdd;

            var progressrepair='PROGRESSREPAIR'+i
            var progressRepairAdd=$("td[name='"+progressrepair+"']").text()==''?0:parseInt($("td[name='"+progressrepair+"']").text());
            progressRepair+=progressRepairAdd;
//
            var progressoutsrc='PROGRESSOUTSRC'+i
            var progressOutsrcAdd=$("td[name='"+progressoutsrc+"']").text()==''?0:parseInt($("td[name='"+progressoutsrc+"']").text());
            progressOutsrc+=progressOutsrcAdd;

            var progressscrap='PROGRESSSCRAP'+i
            var progressScrapAdd=$("td[name='"+progressscrap+"']").text()==''?0:parseInt($("td[name='"+progressscrap+"']").text());
            progressScrap+=progressScrapAdd;

            var progressstepsum='PROGRESSSTEPSUM'+i
            var progressStepSumAdd=$("td[name='"+progressstepsum+"']").text()==''?0:parseInt($("td[name='"+progressstepsum+"']").text());
            progressStepSum+=progressStepSumAdd;


        }



        $("td[name='progressWaitShow']").html(progressWait);
        $("td[name='progressRunShow']").html(progressRun);
        $("td[name='progressHoldShow']").html(progressHold);
        $("td[name='progressRepairShow']").html(progressRepair);
        $("td[name='progressOutsrcShow']").html(progressOutsrc);
        $("td[name='progressScrapShow']").html(progressScrap);
        $("td[name='progressStepSum']").html(progressStepSum);



    })
</script>
